/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.dtgenerator.core.rtgen.lcpgenerator.method;


import com.inspur.edp.bef.dtgenerator.core.rtgen.lcpgenerator.LcpClassGeneratorContext;
import com.inspur.edp.caf.generator.baseInfo.ParameterInfo;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import java.util.ArrayList;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;

public class LcpDefaultConstructorGenerator extends ClassMethodGenerator {

  private LcpClassGeneratorContext lcpClassGenContext;

  public LcpDefaultConstructorGenerator(LcpClassGeneratorContext lcpClassGenContext) {
    super();
    this.lcpClassGenContext = lcpClassGenContext;
  }

  @Override
  protected boolean buildIsConstructor() {
    return true;
  }

@Override
  protected java.util.ArrayList<Modifier.ModifierKeyword> getAccessModifiers() {
    ArrayList<Modifier.ModifierKeyword> list = new ArrayList<Modifier.ModifierKeyword>();
    list.add(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
    return list;
  }

  protected static final String ParSessionId = "sessionId";

  @Override
  protected ArrayList<ParameterInfo> getParameterCollection() {
    ArrayList<ParameterInfo> pars = new ArrayList<>(1);
    ParameterInfo par = new ParameterInfo();
    par.setParamName(ParSessionId);
    par.setParamType(new TypeInfo(String.class));
    pars.add(par);
    return pars;
  }

  @Override
  protected String getMethodName() {
    return lcpClassGenContext.getProjContext().getBE().getCode();
  }

  @Override
  protected TypeInfo getReturnType() {
    return null;
  }

  @Override
  protected Block buildMethodBody() {
    Block block = ast.newBlock();
    SuperConstructorInvocation superConstructorInvocation = ast.newSuperConstructorInvocation();
    superConstructorInvocation.arguments().add(ast.newSimpleName(ParSessionId));
    block.statements().add(superConstructorInvocation);
    return block;
  }

//protected override ConstructorInitializerType BuildConstructorInitializerType()
  //{
  //    return ConstructorInitializerType.Base;
  //}

  //protected override List<SyntaxNodeOrToken> BuildConstructorInitializerParams()
  //{
  //    var initializerParams = new List<SyntaxNodeOrToken>();
  //    initializerParams.Add(SyntaxFactory.Argument(
  //        SyntaxFactory.IdentifierName("sessionId")));
  //    return initializerParams;
  //}
}
